package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build.VERSION;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import o.dky.j;

public abstract class NetWorkUtil {
    private static String FLAG_WIFI = "Wi-Fi";
    private static boolean isGMSCLosed = false;
    private static String FLAG_WLAN = "WLAN";
    private static String FLAG_WIF_1 = "WI-FI";
    private static String FLAG_WIF_2 = "WiFi";

    public static void setWIfi(Context context, String str) {
        try {
            Intent intent = new Intent();
            if (!(context instanceof Activity)) {
                intent.setFlags(268435456);
            }
            int i = VERSION.SDK_INT;
            if (i >= 9) {
                intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
                intent.setData(Uri.fromParts(HiAnalyticsConstant.BI_KEY_PACKAGE, str, null));
            } else {
                String str2 = 8 == i ? "pkg" : "com.android.settings.ApplicationPkgName";
                intent.setAction(ACTION.HWID_SCHEME_URL);
                intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
                intent.putExtra(str2, str);
            }
            context.startActivity(intent);
        } catch (Exception e) {
            Logger.ˋ("AppSettingUtil", "showInstalledAppDetails error");
        }
    }

    public static void getNetInfo(Context context) {
        isGMSCLosed = "156".equals(bmm.getSystemProperty("ro.config.hw_optb", ""));
        if (context != null && context.getResources() != null) {
            FLAG_WLAN = context.getString(j.ˋʽ);
            FLAG_WIF_2 = context.getString(j.ˊʼ);
            FLAG_WIFI = context.getString(j.ˊʻ);
        }
    }

    public static boolean isGMSClose() {
        return isGMSCLosed;
    }

    public static String getWifiResId(Context context, int i) {
        return rebuildWifiKey(context.getString(i));
    }

    public static String rebuildWifiKey(String str) {
        if (str == null) {
            return "";
        }
        if (!isGMSClose() && !ˎ()) {
            return str;
        }
        if (str.contains(FLAG_WIF_2)) {
            return str.replace(FLAG_WIF_2, FLAG_WLAN);
        }
        if (str.contains(FLAG_WIFI)) {
            return str.replace(FLAG_WIFI, FLAG_WLAN);
        }
        if (str.contains(FLAG_WIF_1)) {
            return str.replace(FLAG_WIF_1, FLAG_WLAN);
        }
        return str;
    }

    private static boolean ˎ() {
        return PackageUtils.HWGAMEBOX_PACKAGE_NAME.equals(ContentManager.getInstant().getContext().getPackageName());
    }
}
